/**
 * Created by Juvid on 2017/3/22.
 */

import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    TouchableHighlight,
    TouchableOpacity,
    Text,
    View
} from 'react-native';
import JuButton from './JuCompoent/JuButton'

export default class MyButton extends React.Component {
    constructor(props){
    super(props);
    this.state = {

    };
    this._TheTestTitle = this._TheTestTitle.bind(this);
}
    _onPressButton(e) {
        console.log(e);
    }
    _onPLongPress() {
        console.log("You tappedLong the button!");
    }
    _TheTestTitle(){
        return(
            <View style={{marginLeft:15,height:40,backgroundColor : '#0f0',marginTop:40,marginBottom:10}}>
                <TestTitle title="自定义按钮" style={{height:40,backgroundColor :'#ff0'}}
                           onTouch = {(e) => {
                this._onPressButton(e)
            }}/></View>
        );
    }

    render() {
        return (
            <View>
                {this._TheTestTitle()}
                <TouchableHighlight style={{flexDirection: 'row',marginLeft:15,height:40,backgroundColor : '#0ff'}}
                                    onPress={this._onPressButton} onLongPress={this._onPLongPress}>
                    <Text>Button</Text>
                </TouchableHighlight>
            </View>
        );
    }
}
class TestTitle extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        // 根据当前showText的值决定是否显示text内容
        return (
            <JuButton underlayColor="#eee" title={this.props.title} style={this.props.style} onTouch = {(e) => {
                return  this.props.onTouch("你点了他哦!")}}
            >
            </JuButton>
        );
    }
}


